import { request, requestMock } from "@/utils/http";

// 请求三级列表
export const requestNavTypeList = () => {
  return request.get("/api/product/getBaseCategoryList")
}

// 请求banner轮播图
export const requestBannerList = () => {
  return requestMock.get("/banner")
}

// 请求floor轮播图
export const requestFloorList = () => {
  return requestMock.get("/floor")
}

// search请求
export const requestSearchList = (params) => {
  return request.post("/api/list", params)
}

// detail请求
export const requestDetailInfo = (skuId) => {
  return request.get(`/api/item/${skuId}`)
}

// 添加到购物车,对已有物品进行数量改动请求
export const requestAddOrUpdataNumCart = ({ skuId, skuNum }) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}

// 获取购物车列表
export const requestShopCart = () => {
  return request.get("/api/cart/cartList")
}

// 切换单个商品选中状态请求
export const requestSingleGoodChecked = ({ skuId, isChecked }) => {
  return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}

// 全选状态请求
export const requestAllGoodsChecked = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)
}

// 删除单个请求
export const requestDeleteGood = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`)
}

// 删除全部请求
export const requestDeleteAllGoods = (skuIdList) => {
  return request.delete(`/api/cart/batchDeleteCart`, {
    data: skuIdList
  })
}

// 获取验证码请求
export const requestCode = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`)
}

// 注册请求
export const requestRegister = (userInfo) => {
  return request.post("/api/user/passport/register", userInfo)
}

// 登录请求
export const requestLogin = (userInfo) => {
  return request.post("/api/user/passport/login", userInfo)
}

// 用户信息请求
export const requestUserInfo = () => {
  return request.get("/api/user/passport/auth/getUserInfo")
}

// 退出登录请求
export const requestLogout = () => {
  return request.get("/api/user/passport/logout")
}

// 订单交易页请求
export const requestTradeList = () => {
  return request.get("/api/order/auth/trade")
}

// 用户地址请求
export const requestAddress = () => {
  return requestMock.get("/address")
}

// 提交订单请求
export const requestTradeInfo = (tradeNo, tradeInfo) => {
  return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, tradeInfo)
}

// 获取订单支付信息
export const requestPayInfo = (orderId) => {
  return request.get(`/api/payment/weixin/createNative/${orderId}`)
}

// 查询订单支付状态
export const requestPayStatus = (orderId) => {
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}

// 获取订单列表
export const requestOrderList = ({ page, limit }) => {
  return request.get(`/api/order/auth/${page}/${limit}`)
}